<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>以逗号形式分隔</title>
</head>
<body>
<script>
    let str = 'trim trim,trims，trim'
    let newStr = '';
    for (let i = 0; i < str.length; i++) {
        if (str[i].includes('，') || str[i].includes(' ')) {
            newStr += ','
        } else {
            newStr += str[i];
        }
    }
    console.log(newStr)
</script>
</body>
</html>
